import { request } from '@/utils/request'
import type { CartVo } from "./types.ts"


const baseUrl = '/api/user/cart'

/* 添加购物车 */
export const addCartApi = (data : { skuId : string; count : number }) => {
	return request<CartVo[]>({
		url: baseUrl,
		method: 'POST',
		data
	})
}


/* 修改购物车商品数量 */
export const updateNumberApi = (data : { id : string; selected? : boolean; count? : number; }) => {
	return request({
		url: baseUrl + `/updateNumber`,
		method: 'PUT',
		data
	})
}

/* 购物车全选-取消 */
export const isCheckedAllApi = (data : { selected : boolean; }) => {
	return request({
		url: baseUrl + `/isCheckedAll`,
		method: 'PUT',
		data
	})
}

/** 购物车列表 */

export const getCatListApi = (query ?: any) : any => {
	return request<CartVo[]>({
		url: baseUrl + '/list',
		method: 'GET',
		data: { query }
	})
}

/* 删除购物车商品 */
export const delSkuGoodsApi = (id : string | number | Array<string | number>) => {
	return request({
		url: baseUrl + `/${id}`,
		method: 'DELETE',

	})
}